<!doctype html>
<title>Cache Storage: verify resources larger than 256MB can be put into a Cache</title>
<meta name="timeout" content="long">
<link rel="help" href="https://w3c.github.io/ServiceWorker/#cache-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

// Note, this is a manual test due to the excessive amount of storage used.
promise_test(async t => {
  const cache = await caches.open('large-test');
  t.add_cleanup(() => caches.delete('large-test'));

  const url = '/large-test';

  // Body string that is greater than 256MB assuming one byte characters.
  // Older versions of cache_storage limited responses to 256MB or less.
  // (crbug.com/653630)
  const body = 'a'.repeat(1024 * 1024 * 257);

  let response = new Response(body);
  await cache.put(url, response);

  response = await cache.match(url);
  const result = await response.blob();
  assert_equals(body.length, result.size);
}, 'Cache can store resources larger than 256MB.');

</script>
